package com.example.controller;

import com.example.pojo.Administer;
import com.example.service.AdministerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.yaml.snakeyaml.events.Event;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 名称AdministerController
 * 描述AdministerController
 *
 * @version 1.0
 * @author:wanghao
 * @datatime:2023,04,16,14,53
 */
@Controller
public class AdministerController {
    @Autowired
    private AdministerService administerService;

    @RequestMapping("/AdministerLoginPage")
    public String AdministerLoginPage(){return "AdministerLoginPage";}

    @ResponseBody
    @RequestMapping("/AdministerLogin")
    public String AdministerLogin(@RequestParam(value = "name")String name,@RequestParam(value = "passwd")String passwd){
        if (administerService.CheckAdminPasswd(name, passwd).equals("true")){
            return "Succeed";
        }
        else return "something wrong";
    }

    @RequestMapping("/RegisterAdministerPage")
    public String RegisterAdministerPage(){return "RegisterAdministerPage";}

    @RequestMapping("/RegisterAdminister")
    @ResponseBody
    public String RegisterAdminister(Administer administer){
        int i= administerService.InsertAdminister(administer);
        if (i>0)   {return "Succeed";}
        else {return "something wrong";}
    }

}
